package com.ruoyi.web.controller.orderview;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.orderview.domain.StaticProcess;
import com.ruoyi.orderview.service.IStaticProcessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * VIEWController
 *
 * @author ruoyi
 * @date 2022-02-20
 */
@RestController
@RequestMapping("/system/process")
public class StaticProcessController extends BaseController
{
    @Autowired
    private IStaticProcessService staticProcessService;

    /**
     * 查询VIEW列表
     */
    //@PreAuthorize("@ss.hasPermi('system:process:list')")
    @GetMapping("/list")
    public TableDataInfo list(StaticProcess staticProcess)
    {
        startPage();
        List<StaticProcess> list = staticProcessService.selectStaticProcessList(staticProcess);
        return getDataTable(list);
    }

    /**
     * 导出VIEW列表
     */
    //@PreAuthorize("@ss.hasPermi('system:process:export')")
    @Log(title = "VIEW", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(StaticProcess staticProcess)
    {
        List<StaticProcess> list = staticProcessService.selectStaticProcessList(staticProcess);
        ExcelUtil<StaticProcess> util = new ExcelUtil<StaticProcess>(StaticProcess.class);
        return util.exportExcel( list, "VIEW数据");
    }

    /**
     * 获取VIEW详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:process:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(staticProcessService.selectStaticProcessById(id));
    }

    /**
     * 新增VIEW
     */
//    @PreAuthorize("@ss.hasPermi('system:process:add')")
    @Log(title = "VIEW", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StaticProcess staticProcess)
    {
        return toAjax(staticProcessService.insertStaticProcess(staticProcess));
    }

    /**
     * 修改VIEW
     */
//    @PreAuthorize("@ss.hasPermi('system:process:edit')")
    @Log(title = "VIEW", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StaticProcess staticProcess)
    {
        return toAjax(staticProcessService.updateStaticProcess(staticProcess));
    }

    /**
     * 删除VIEW
     */
//    @PreAuthorize("@ss.hasPermi('system:process:remove')")
    @Log(title = "VIEW", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(staticProcessService.deleteStaticProcessByIds(ids));
    }
}
